package com.weixingtu.commuterCar.tool.gps;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.weixingtu.commuterCar.bean.Device;

import java.util.Date;
import java.util.List;

public class GPSInfo {
    private String serviceUrl;
    private String appId;
    private String key;
    private List<String> imei;
    private String accessToken;

    public GPSInfo(){

    }
    public GPSInfo(String url){
        this.serviceUrl = url;
    }
    public GPSInfo(String url,String appId,String key){
        this.serviceUrl = url;
        this.appId = appId;
        this.key = key;
    }

    public String getServiceUrl() {
        return serviceUrl;
    }

    public void setServiceUrl(String serviceUrl) {
        this.serviceUrl = serviceUrl;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public List<String> getImei() {
        return imei;
    }

    public void setImei(List<String> imei) {
        this.imei = imei;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getAccessToken() {
        return accessToken;
    }

    /**
     * translate jsonString to map
     * @param jsonString
     * @return int
     */
    public JSONObject getMapRet(String jsonString){
        if(jsonString==null){
            return null;
        }
        JSONObject jsonObject = (JSONObject) JSON.parse(jsonString, Feature.OrderedField);
        return jsonObject;

    }

    /**
     * 获取以秒为单位的Unix时间戳
     * @return
     */
    public static int getSecondTimestampTwo(){
        Date date = new Date();
        if (null == date) {
            return 0;
        }
        String timestamp = String.valueOf(date.getTime()/1000);
        return Integer.valueOf(timestamp);
    }
}
